package com.fireXXX.job.analysis.crawler.common.company;

import com.fireXXX.job.analysis.crawler.boss.constant.*;
import com.fireXXX.job.analysis.crawler.common.Page;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CompanyTask implements Runnable {

    private CompanyCrawler crawler;
    private CityTypeEnum city;
    private IndustryTypeEnum industry;
    private PublicStepTypeEnum publicStep;
    private EmployeeNumberTypeEnum employeeNumber;
    private Page page;

    private int sleep = 5000;

    public CompanyTask(CompanyCrawler crawler, CityTypeEnum city, IndustryTypeEnum industry, PublicStepTypeEnum publicStep, EmployeeNumberTypeEnum employeeNumber, Page page) {
        this.crawler = crawler;
        this.city = city;
        this.industry = industry;
        this.publicStep = publicStep;
        this.employeeNumber = employeeNumber;
        this.page = page;
    }

    @SneakyThrows
    @Override
    public void run() {
//        try {
            crawler.crawl(city, industry, publicStep, employeeNumber, page);

            Thread.sleep(sleep);
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error(String.format("crawlPage city(%s) industry(%s) publicStep(%s) employeeNumber(%s), err(%s)", city, industry.getText(), publicStep.getText(), employeeNumber.getText(),
//                    ExceptionUtil.getFirstNonNullMessage(e)));
//        }
    }
}
